home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Headers / SCODE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-22  |  10.6 KB  |  284 lines  |  [TEXT/????]

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * scode.h -     Defines standard status code services.                          *
  4. *                                                                             *
  5. *               OLE Version 2.0                                               *
  6. *                                                                             *
  7. *               Copyright (c) 1992-1994, Microsoft Corp. All rights reserved. *
  8. *                                                                             *
  9. \*****************************************************************************/
  10.  
  11.  
  12. #if !defined(__SCODE__) && !defined(_SCODE_H_)
  13. #define __SCODE__
  14. #define _SCODE_H_
  15.  
  16. //
  17. // SCODE
  18. //
  19.  
  20. typedef long SCODE;
  21. typedef SCODE *PSCODE;
  22. //typedef void  * HRESULT;
  23. typedef long HRESULT;
  24. #define NOERROR 0
  25.  
  26. //
  27. //  Status values are 32 bit values layed out as follows:
  28. //
  29. //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  30. //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  31. //  +-+---------------------+-------+-------------------------------+
  32. //  |S|       Context       | Facil |               Code            |
  33. //  +-+---------------------+-------+-------------------------------+
  34. //
  35. //  where
  36. //
  37. //      S - is the severity code
  38. //
  39. //          0 - Success
  40. //          1 - Error
  41. //
  42. //      Context - context info
  43. //
  44. //      Facility - is the facility code
  45. //
  46. //      Code - is the facility's status code
  47. //
  48.  
  49. //
  50. // Severity values
  51. //
  52.  
  53. #define SEVERITY_SUCCESS    0
  54. #define SEVERITY_ERROR      1
  55.  
  56.  
  57.  
  58. #define SUCCEEDED(Status) ((SCODE)(Status) >= 0)
  59.  
  60. #define FAILED(Status) ((SCODE)(Status)<0)
  61.  
  62.  
  63. //
  64. // Return the code
  65. //
  66.  
  67. #define SCODE_CODE(sc)      ((sc) & 0xFFFF)
  68.  
  69. //
  70. //  Return the facility
  71. //
  72.  
  73. #define SCODE_FACILITY(sc)  (((sc) >> 16) & 0x1fff)
  74.  
  75. //
  76. //  Return the severity
  77. //
  78.  
  79. #define SCODE_SEVERITY(sc)  (((sc) >> 31) & 0x1)
  80.  
  81. //
  82. // Create an SCODE value from component pieces
  83. //
  84.  
  85. #define MAKE_SCODE(sev,fac,code) \
  86.     ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  87.  
  88.  
  89.  
  90. // --------------------- Functions ---------------------------------------
  91.  
  92. #define GetScode(hr)         ((SCODE)(hr) & 0x800FFFFF)
  93. #define ResultFromScode(sc) ((HRESULT)((SCODE)(sc) & 0x800FFFFF))
  94.  
  95. STDAPI PropagateResult(HRESULT hrPrev, SCODE scNew);
  96.  
  97.  
  98. // -------------------------- Facility definitions -------------------------
  99.  
  100. #define FACILITY_NULL       0x0000 // generally useful errors ([SE]_*)
  101. #define FACILITY_RPC            0x0001 // remote procedure call errors (RPC_E_*)
  102. #define FACILITY_DISPATCH   0x0002 // late binding dispatch errors
  103. #define FACILITY_STORAGE   0x0003 // storage errors (STG_E_*)
  104. #define FACILITY_ITF            0x0004 // interface-specific errors
  105.  
  106.  
  107.  
  108. #define S_OK                0L
  109. #define S_FALSE             MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  110.  
  111.  
  112.  
  113. // --------------------- FACILITY_NULL errors ------------------------------
  114.  
  115. #define E_UNEXPECTED        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 0xffff)
  116.                             // relatively catastrophic failure
  117.  
  118. #define E_NOTIMPL           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 1)
  119.                             // not implemented
  120.  
  121. #define E_OUTOFMEMORY       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 2)
  122.                             // ran out of memory
  123.  
  124. #define E_INVALIDARG        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 3)
  125.                             // one or more arguments are invalid
  126.  
  127. #define E_NOINTERFACE       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 4)
  128.                             // no such interface supported
  129.  
  130.  
  131. #define E_POINTER           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 5)
  132.                             // invalid pointer
  133.  
  134. #define E_HANDLE            MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 6)
  135.                             // invalid handle
  136.  
  137. #define E_ABORT             MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 7)
  138.                             // operation aborted
  139.  
  140. #define E_FAIL              MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 8)
  141.                             // unspecified error
  142.  
  143.  
  144. #define E_ACCESSDENIED      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 9)
  145.                             // general access denied error
  146.  
  147.  
  148. // ----------------- FACILITY_ITF errors used by OLE ---------------------
  149. //
  150. // By convention, OLE interfaces divide the FACILITY_ITF range of errors
  151. // into nonoverlapping subranges.  If an OLE interface returns a FACILITY_ITF 
  152. // scode, it must be from the range associated with that interface or from
  153. // the shared range: OLE_E_FIRST...OLE_E_LAST.
  154. //
  155. // The ranges, their associated interfaces, and the header file that defines
  156. // the actual scodes are given below.
  157. // 
  158.  
  159. // Generic OLE errors that may be returned by many interfaces
  160. #define OLE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0000)
  161. #define OLE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x00FF)
  162. #define OLE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0000)
  163. #define OLE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x00FF)
  164. // interfaces: all
  165. // file: ole2.h
  166.  
  167.  
  168. #define DRAGDROP_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0100)
  169. #define DRAGDROP_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x010F)
  170. #define DRAGDROP_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0100)
  171. #define DRAGDROP_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x010F)
  172. // interfaces: IDropSource, IDropTarget
  173. // file: ole2.h
  174.  
  175. #define CLASSFACTORY_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0110)
  176. #define CLASSFACTORY_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x011F)
  177. #define CLASSFACTORY_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0110)
  178. #define CLASSFACTORY_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x011F)
  179. // interfaces: IClassFactory
  180. // file:
  181.  
  182. #define MARSHAL_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0120)
  183. #define MARSHAL_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x012F)
  184. #define MARSHAL_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0120)
  185. #define MARSHAL_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x012F)
  186. // interfaces: IMarshal, IStdMarshalInfo, marshal APIs
  187. // file:
  188.  
  189. #define DATA_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0130)
  190. #define DATA_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x013F)
  191. #define DATA_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0130)
  192. #define DATA_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x013F)
  193. // interfaces: IDataObject
  194. // file: dvobj.h
  195.  
  196. #define VIEW_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0140)
  197. #define VIEW_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x014F)
  198. #define VIEW_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0140)
  199. #define VIEW_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x014F)
  200. // interfaces: IViewObject
  201. // file: dvobj.h
  202.  
  203. #define REGDB_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0150)
  204. #define REGDB_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x015F)
  205. #define REGDB_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0150)
  206. #define REGDB_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x015F)
  207. // API: reg.dat manipulation
  208. // file: 
  209.  
  210.  
  211. // range 160 - 16F reserved
  212.  
  213. #define CACHE_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0170) 
  214. #define CACHE_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x017F)
  215. #define CACHE_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0170)
  216. #define CACHE_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x017F)
  217. // interfaces: IOleCache
  218. // file:
  219.  
  220. #define OLEOBJ_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0180)
  221. #define OLEOBJ_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x018F)
  222. #define OLEOBJ_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0180)
  223. #define OLEOBJ_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x018F)
  224. // interfaces: IOleObject
  225. // file:
  226.  
  227. #define CLIENTSITE_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0190) 
  228. #define CLIENTSITE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x019F)
  229. #define CLIENTSITE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0190)
  230. #define CLIENTSITE_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x019F)
  231. // interfaces: IOleClientSite
  232. // file:
  233.  
  234. #define INPLACE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01A0)
  235. #define INPLACE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01AF)
  236. #define INPLACE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01A0)
  237. #define INPLACE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01AF)
  238. // interfaces: IOleWindow, IOleInPlaceObject, IOleInPlaceActiveObject,
  239. //                 IOleInPlaceUIWindow, IOleInPlaceFrame, IOleInPlaceSite
  240. // file:
  241.  
  242. #define ENUM_E_FIRST        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01B0)
  243. #define ENUM_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01BF)
  244. #define ENUM_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01B0)
  245. #define ENUM_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01BF)
  246. // interfaces: IEnum*
  247. // file:
  248.  
  249. #define CONVERT10_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01C0)
  250. #define CONVERT10_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01CF)
  251. #define CONVERT10_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01C0)
  252. #define CONVERT10_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01CF)
  253. // API: OleConvertOLESTREAMToIStorage, OleConvertIStorageToOLESTREAM
  254. // file:
  255.  
  256.  
  257. #define CLIPBRD_E_FIRST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01D0)
  258. #define CLIPBRD_E_LAST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01DF)
  259. #define CLIPBRD_S_FIRST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01D0)
  260. #define CLIPBRD_S_LAST      MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01DF)
  261. // interfaces: OleSetClipboard, OleGetClipboard, OleFlushClipboard
  262. // file: ole2.h
  263.  
  264. #define MK_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01E0)
  265. #define MK_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01EF)
  266. #define MK_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01E0)
  267. #define MK_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01EF)
  268. // interfaces: IMoniker, IBindCtx, IRunningObjectTable, IParseDisplayName,
  269. //             IOleContainer, IOleItemContainer, IOleLink
  270. // file: moniker.h
  271.  
  272.  
  273. #define CO_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01F0)
  274. #define CO_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01FF)
  275. #define CO_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01F0)
  276. #define CO_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01FF)
  277. // all Co* API
  278. // file: compobj.h
  279.  
  280.  
  281. // range 200 - ffff for new error codes
  282.  
  283. #endif    /* !__SCODE__ */
  284.